const pages = import.meta.glob('@/pages/**/*.vue')

console.log(pages)

const content = Object.keys(pages).map(path => {
  const name = path.match(/.*\/pages\/(.*)\.vue$/)[1]
 
  return {
    path: `/${name.toLowerCase()}`,
    component: pages[path],
    name,

    // meta: {
    //   title: '首页', //菜单名称
    //   roles: ['user', 'admin'], //当前菜单哪些角色可以看到
    //   icon: 'el-icon-info', //菜单左侧的icon图标
    // },
  }
})

export const routes = [
  { path: '/', redirect: '/dashboard' },
  {
    path: '/',
    component: () => import('@/layouts/default.vue'),
    children: content,
  },
  {
    path: '/',
    component: () => import('@/layouts/blank.vue'),
    children: [
      {
        path: 'login',
        component: () => import('@/views/login.vue'),
      },
      {
        path: 'register',
        component: () => import('@/views/register.vue'),
      },
      {
        path: '/:pathMatch(.*)*',
        component: () => import('@/pages/[...error].vue'),
      },
    ],
  },
]
